<template>
  <div class="article-card">
    <!-- 文章标题 -->
    <h2 class="article-title">{{ title }}</h2>

    <!-- 文章简介 -->
    <p class="article-summary">{{ summary }}</p>

    <!-- 文章元信息 -->
    <div class="article-meta">
      <span class="category">{{ category }}</span>
      <span class="date">{{ date }}</span>
    </div>
  </div>
</template>

<script setup>
// 接收具体的属性
defineProps({
  title: {
    type: String,
    required: true,
  },
  summary: {
    type: String,
    required: true,
  },
  category: {
    type: String,
    required: true,
  },
  date: {
    type: String,
    required: true,
  },
});
</script>

<style scoped>
.article-card {
  background-color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden; /* 防止内容溢出 */
}

.article-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.article-title {
  font-size: 1.5rem;
  color: #1a73e8;
  margin-bottom: 10px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap; /* 标题超过一行省略 */
}

.article-summary {
  font-size: 1rem;
  color: #555;
  margin-bottom: 15px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3; /* 简介超过三行省略 */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: #888;
}

.category {
  background-color: #e3f2fd;
  color: #1a73e8;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.date {
  font-style: italic;
}
</style>